package mshop.com.schild_kotlin.mvp.presenter

import android.content.Context
import io.reactivex.Observable
import mshop.com.schild_kotlin.base.applySchedulers
import mshop.com.schild_kotlin.entitys.FindBean
import mshop.com.schild_kotlin.mvp.base.BaseContract
import mshop.com.schild_kotlin.mvp.base.BasePresenter
import mshop.com.schild_kotlin.mvp.model.FindModel
import mshop.com.schild_kotlin.network.MyObserver

/**
 * Created by mayi on 2018/5/27.
 * @Autor CaiWF
 * @Email 401885064@qq.com
 * @TODO  发现
 */
class FindPresenter(val mContext: Context, val view: BaseContract.View<MutableList<FindBean>>) : BasePresenter, BaseContract.Presenter {


    val model: FindModel by lazy {
        FindModel()
    }

    override fun start() {
        requestData()
    }

    override fun requestData() {
            val observerable: Observable<MutableList<FindBean>> = model.loadData(mContext)
            observerable.applySchedulers().subscribe (object :MyObserver<MutableList<FindBean>>(mContext){

                override fun onNext(t: MutableList<FindBean>) {
                    view.setData(t)
                }
            })

    }

}